
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="../../style/css/style.css" rel="stylesheet" type="text/css" />
    <script src="../../style/js/jquery-1.8.3.min.js"></script>
    <script src="../../style/js/ajaxfileupload.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            var  id =(location.search).split("=")[1];
            //查询所有信息
            $.get("../../web/findweb",{id:id},function (res){
            console.log(res);
                $("input[name='title']").val(res.data.title);
               // $("input[name='logoImgSrc']").val(res.data.logoImgSrc);
                var  imgsrc ="http://127.0.0.1:8080/UploadImg/logoImgSrc/"+res.data.newFileName;
                $("#logoImgSrc").html("<img src=" + imgsrc + " height='50' width='50'>");
                $("input[name='recordation']").val(res.data.recordation);
                $("input[name='companyName']").val(res.data.companyName);
                $("input[name='tel']").val(res.data.tel);
            },"json");
        })
        //修改保存成功
        function subform() {
            var  id =(location.search).split("=")[1];
            var title =$("#title").val();
          //  var logoImgSrc =$("#logoImgSrc").val();
            var recordation =$("#recordation").val();
            var companyName =$("#companyName").val();
            var tel =$("#tel").val();
           /* $.post("../../web/update",{title:title,logoImgSrc:logoImgSrc,recordation:recordation,companyName:companyName,tel:tel,id:id},function (res) {
                if (res.code==200){
                    alert("修改成功!!");
                    location.assign("list.html");
                }else {
                    alert("服器忙碌");
                }
            });*/
            $.ajaxFileUpload({
                url: '../../web/update', //用于文件上传的服务器端请求地址  调用后端接口(interface)
                fileElementId: 'logoImgSrc', //文件上传域的ID
                dataType: 'json', //返回值类型 一般设置为json
                data: {
                    id:id,
                    title : title,
                    recordation : recordation,
                    companyName : companyName,
                    tel : tel
                },
                success: function (data) {
                    alert(data.msg);
                    if (data.code == 200) {
                        alert("修改成功");
                        location.replace("list.html");
                    }else{
                        alert("修改失败");
                    }
                }}
            )
        }
        </script>
</head>

<body>
<form id="formId">
    <div class="formbody">
        <div class="formtitle"><span>基本信息</span></div>
        <ul class="forminfo">
            <li>
                <label>网站标题名</label>
                <input class="dfinput"  name="title"  id="title"  type="text"/>
            </li>
            <li>
                <label>logo图片链接</label>
<!--                <input class="dfinput"  name="logoImgSrc"  id="logoImgSrc" type="text"/>-->
                <input class="dfinput"  name="logoImgSrc" id="logoImgSrc" type="file" accept=".jpg,.png,.gif"/>

            </li>
            <li>
                <label>网站备案号</label>
                <input class="dfinput"  name="recordation" id="recordation" type="text"/>
            </li>
            <li>
                <label>公司名称</label>
                <input class="dfinput"  name="companyName"  id="companyName" type="text"/>
            </li>
            <li>
                <label>联系方式</label>
                <input class="dfinput"  name="tel"  id="tel"  type="text"/>
            </li>
            <li>
                <input name="" type="button" class="btn" value="确认修改" onclick="subform()"/>
            </li>
        </ul>
    </div>
</form>

</body>
</html>